//
//  ReadingMeterTaskCell.swift
//  Employee
//
//  Created by tancheng on 2018/6/23.
//  Copyright © 2018年 remotevillage. All rights reserved.
//

import UIKit
import SwiftDate

class ReadingMeterTaskCell: UITableViewCell {

    static let reuseIdentifer = "ReadingMeterTaskCell"
    
    @IBOutlet weak var taskTime: UILabel!
    
    @IBOutlet weak var taskContent: UILabel!
    
    @IBOutlet weak var tipImg: UIImageView!
    @IBOutlet weak var tipLab: UILabel!
    
    @IBOutlet weak var showImg: UIImageView!
    
    var isShowExpired = true
    
    var model: ReadingMeterTaskModel! {
        didSet {
            updateData()
        }
    }
    
    
    func updateData() {
        
        tipImg.isHidden = !model.cooperation
        tipLab.isHidden = !model.cooperation
        
        taskContent.text = model.title
        
        let readDate = try? model.meterReadDate.date(format: .custom("yyyy-MM"))
        
        taskTime.text = readDate?.string(custom: "yyyy年MM月")
        
        
        showImg.isHidden = model.status == .waitCommit
        
        
        showImg.image = UIImage(named: model.status == .expired ? "show-list-icon-blue" : "show-list-icon-grey")
        
        taskContent.textColor = model.status == .submission ? GlobalConfig.TextDeepColor.withAlphaComponent(0.2) : GlobalConfig.TextDeepColor
        
        taskTime.textColor = model.status == .submission ? GlobalConfig.TextDeepColor.withAlphaComponent(0.2) : GlobalConfig.BGSkyBlueColor
        
        tipLab.textColor = model.status == .submission ? GlobalConfig.TextDeepColor.withAlphaComponent(0.2) : GlobalConfig.TextDeepColor.withAlphaComponent(0.5)
        
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        selectionStyle = .none
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
